package com.example.android_common.util;

import android.util.Log;

/**
 * 调试日志 ，调试Toast
 * 		DebugUtils.e 
 * 		DebugUtils.w 
 * 		DebugUtils.i 
 * 		DebugUtils.d 
 * 		DebugUtils.v
 * 
 * 		DebugUtils.debugToast(String msg)
 * 		DebugUtils.debugToast(int resID)
 * 
 * @author hubin
 * @email 7629654@qq.com
 * @date 2014-11-3
 */
public class DebugUtils {
	/** 日志开关 */
	public static boolean controller = true;
	/** 日志等级 */
	public static int LOG_LEVEL = 6;
	public static int ERROR = 1;
	public static int WARN = 2;
	public static int INFO = 3;
	public static int DEBUG = 4;
	public static int VERBOS = 5;

	public static void e(String tag, String msg) {
		if (controller && LOG_LEVEL > ERROR)
			Log.e(tag, msg);
	}

	public static void e(Class<?> clazz, String msg) {
		if (controller && LOG_LEVEL > ERROR)
			Log.e(clazz.getSimpleName(), msg);
	}

	public static void w(String tag, String msg) {
		if (controller && LOG_LEVEL > WARN)
			Log.w(tag, msg);
	}

	public static void w(Class<?> clazz, String msg) {
		if (controller && LOG_LEVEL > WARN)
			Log.w(clazz.getSimpleName(), msg);
	}

	public static void i(String tag, String msg) {
		if (controller && LOG_LEVEL > INFO)
			Log.i(tag, msg);
	}

	public static void i(Class<?> clazz, String msg) {
		if (controller && LOG_LEVEL > INFO)
			Log.i(clazz.getSimpleName(), msg);
	}

	public static void d(String tag, String msg) {
		if (controller && LOG_LEVEL > DEBUG)
			Log.d(tag, msg);
	}

	public static void d(Class<?> clazz, String msg) {
		if (controller && LOG_LEVEL > DEBUG)
			Log.d(clazz.getSimpleName(), msg);
	}

	public static void v(String tag, String msg) {
		if (controller && LOG_LEVEL > VERBOS)
			Log.v(tag, msg);
	}

	public static void v(Class<?> clazz, String msg) {
		if (controller && LOG_LEVEL > VERBOS)
			Log.v(clazz.getSimpleName(), msg);
	}
	
	/**
	 * 显示调试Toast
	 * @param message
	 */
//	private static Toast toast;
//	public static void debugToast(String message){
//		if(!controller)return;
//		if (toast != null)
//			toast.cancel();
//		toast = Toast.makeText(FeifeiWeightApplication.getInstance(), message, Toast.LENGTH_SHORT);
//		toast.show();
//	}
	/**
	 * 显示调试Toast
	 * @param resID
	 */
//	public static void debugToast(int resID) {
//		if(!controller)return;
//		if (toast != null)
//			toast.cancel();
//		toast = Toast.makeText(FeifeiWeightApplication.getInstance(), resID, Toast.LENGTH_SHORT);
//		toast.show();
//	}

}
